<template>
    <view style="padding: 0 30rpx">
        <!-- <back></back> -->
        <view class="top">
            <view
                class="top_one u-flex u-row-between"
                style="border-bottom: 1rpx solid #dfdfdf"
            >
                <view class="zi">提现</view>
                <!-- @click="$func.jump('/wNew/pages/txlist')" -->
                <view class="u-flex u-row-between">
                    微信账户
                    <!-- <u-icon style="margin-left: 10rpx" name="arrow-right"></u-icon> -->
                </view>
            </view>
            <view class="top_one u-flex u-row-between">
                <view class="zi">提现金额</view>
                <view
                    class="top_gre"
                    @click="$func.jump('/wNew/pages/withdrawalRecords')"
                    >提现记录</view
                >
            </view>
            <view class="int u-flex">
                <image :src="BaseUrl + '/static/wImg/money.png'"></image>
                <input
                    type="number"
                    placeholder="输入提现金额"
                    v-model="money"
                />
            </view>
            <view class="tip">
                当前钱包余额剩余{{ all ? all : 0 }}元，<text @click="getAll()"
                    >全部提现</text
                >
            </view>
        </view>
        <view class="bottom">
            <view class="bot_tit"> 提现说明 </view>
            <rich-text :nodes="html"></rich-text>
        </view>
        <view class="btn u-flex-center" @click="getSubmit()"> 确认提现 </view>
    </view>
</template>

<script>
import { BaseUrl } from "../../utils/req.js";
export default {
    data() {
        return {
            bank: "",
            money: "",
            html: "",
            all: "",
            BaseUrl,
        };
    },
    onShow() {
        console.log(uni.getStorageSync("bank"));
        if (uni.getStorageSync("bank")) {
            this.bank = uni.getStorageSync("bank");
        }
        this.$request
            .post("api/wanlshop.merchant/get_user_tx", {})
            .then((res) => {
                if (res.code == 1) {
                    this.html = res.data.tx_sm;
                    this.all = res.data.money;
                }
            });
    },
    methods: {
        getAll() {
            this.money = this.all;
        },
        getM() {
            this.$request
                .post("api/wanlshop.merchant/get_user_tx", {})
                .then((res) => {
                    if (res.code == 1) {
                        this.html = res.data.tx_sm;
                        this.all = res.data.money;
                    }
                });
        },
        getSubmit() {
            this.$u
                .post("/api/wanlshop.merchant/shop_add_cash", {
                    money: this.money,
                })
                .then((res) => {
                    if (res.code == 1) {
                        var that = this;
                        that.getM();
                        uni.showModal({
                            title: res.msg,
                            showCancel: false,
                            success() {
                                
                            },
                        });
                    } else {
                        uni.showModal({
                            title: res.msg,
                            showCancel: false,
                        });
                    }
                });
        },
    },
};
</script>

<style lang="scss" scoped>
.top {
    width: 100%;
    background: #fff;
    border-radius: 10rpx;
    margin-top: 30rpx;
    padding: 0 30rpx;

    .top_one {
        padding: 30rpx 0;
    }

    .zi {
        font-size: 28rpx;
        font-weight: bold;
    }
    .top_gre {
        font-size: 24rpx;
        color: #606dce;
    }
    .int {
        height: 120rpx;
        background: #f8f8f8;
        border-radius: 20rpx;
        padding: 0 30rpx;
        image {
            width: 40rpx;
            height: 56rpx;
            margin-right: 30rpx;
        }
        input {
            height: 100%;
        }
    }
    .tip {
        font-size: 24rpx;
        color: #888;
        padding: 20rpx 0 47rpx 0;
        text {
            color: #606dce;
        }
    }
}
.bottom {
    background: #ffffff;
    border-radius: 10rpx;
    margin-top: 20rpx;
    padding: 30rpx 30rpx 45rpx;
    .bot_tit {
        font-size: 28rpx;
        font-weight: bold;
        color: #222;
        margin-bottom: 20rpx;
    }
}
.btn {
    width: 630rpx;
    height: 80rpx;
    color: #fff;
    background: linear-gradient(135deg, #2bb984 0%, #8cd994 100%);
    border-radius: 40rpx;
    position: fixed;
    bottom: 100rpx;
    margin: 0 auto;
    left: 0;
    right: 0;
}
</style>
